package vy.org.app.page.lookup.patrika;

import org.vy.dal.dao.lookup.VyLookupPatrikaDO;

import vy.org.util.DateUtil;

public class MntnPatrikaAssembler {

	private static MntnPatrikaAssembler assembler = new MntnPatrikaAssembler();

	public static MntnPatrikaAssembler getAssembler() {
		return assembler;
	}

	public VyLookupPatrikaDO getPatrika(MntnPatrikaForm form) {
		VyLookupPatrikaDO dto = new VyLookupPatrikaDO();
		if (form.getPatrikaCode() != null
				&& !"".equals(form.getPatrikaCode().trim())) {
			dto.setPatrikaId(Integer.parseInt(form.getPatrikaCode()));
		}
		if (form.getPatrikaName() != null
				&& !"".equals(form.getPatrikaName().trim())) {
			dto.setPatrikaName(form.getPatrikaName());
		}
		if (form.getEffectiveDate() != null
				&& !"".equals(form.getEffectiveDate().trim())) {
			dto
					.setEffectiveDate(DateUtil.standardDate(form
							.getEffectiveDate()));
		}
		if (form.getWeekOffset() != null && !"".equals(form.getWeekOffset())) {
			dto.setWeekOffsetIndex(Double.parseDouble(form.getWeekOffset()));
		}
		if (form.getIsDelete() != null && !"".equals(form.getIsDelete().trim())) {

			dto.setIsDeleted(Boolean.valueOf(form.getIsDelete()));
		}

		if (form.getLastUpdatedBy() != null
				&& !"".equals(form.getLastUpdatedBy().trim())) {

			dto.setLastUpdatedBy(form.getLastUpdatedBy());
		}
		if (form.getLastUpdatedOn() != null
				&& !"".equals(form.getLastUpdatedOn().trim())) {

			dto
					.setLastUpdatedOn(DateUtil.standardDate(form
							.getLastUpdatedOn()));
		}
		return dto;

	}

}
